package com.diorsunion.hedge.common;

/**
 * Created by wanglaoshi on 2016/4/23.
 */
public final class ServiceResult<T> {
    public final String code;
    public final boolean success;
    public final String message;
    public final T obj;

    public final static ServiceResult errorResult(String message){
        return new ServiceResult(null,false,message,null);
    }
    public final static <T> ServiceResult errorResult(T obj){
        return new ServiceResult(null,false,null,obj);
    }
    public final static <T> ServiceResult errorResult(T obj,String message){
        return new ServiceResult(null,false,message,obj);
    }
    public final static <T> ServiceResult successResult(T obj){
        return new ServiceResult(null,true,null,obj);
    }
    public final static <T> ServiceResult successResult(T obj,String message){
        return new ServiceResult(null,true,message,obj);
    }
    public final static ServiceResult returnResult(boolean success,String message){
        return new ServiceResult(null,success,message,null);
    }
    public final static ServiceResult returnResult(String code,boolean success,String message){
        return new ServiceResult(code,success,message,null);
    }
    public final static <T> ServiceResult returnResult(String code,boolean success,String message,T obj){
        return new ServiceResult(code,success,message,obj);
    }

    private ServiceResult(String code, boolean success, String message, T obj) {
        this.code = code;
        this.success = success;
        this.message = message;
        this.obj = obj;
    }
}
